package com.lujieni.springbootrocketmq.service;

import com.lujieni.springbootrocketmq.dto.OrderDTO;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * @Author：小鹿爱吃鱼
 * @Date: 2025/6/8 14:47
 * @Description:
 */
@RocketMQMessageListener(
        topic = "test-topic",                 // 监听的 Topic
        consumerGroup = "my-consumer-group",  // 消费者组
        selectorExpression = "lujieni",   // 只消费 tag = a 的消息,tag的匹配是消费者客户端进行匹配的
        maxReconsumeTimes = 3,
        consumeMode = ConsumeMode.ORDERLY     // 一个队列只有一个线程
)
public class MessageConsumerOrder implements RocketMQListener<OrderDTO> {

    @Override
    public void onMessage(OrderDTO OrderDTO) {
        System.out.println("Received order orderly: " + OrderDTO);
        // 业务处理逻辑
    }
}
